package src.Packets;

import src.Main;
import src.Players.Player;
import src.NPCs.NPC;

public class NPCOption1
{
    public NPCOption1(Player p)
    {
        if(p == null || p.inStream == null)
        {
            return;
        }
        if(!p.npcOption1)
        {
            p.clickId = p.inStream.readSignedWordBigEndian();
            if (p.clickId < 1 || p.clickId > Main.m.ge.maxNPCs || Main.m.ge.npcs[p.clickId] == null)
            {
                return;
            }
            p.clickX = Main.m.ge.npcs[p.clickId].absX;
            p.clickY = Main.m.ge.npcs[p.clickId].absY;
            p.npcOption1 = true;
        }
        if(Main.m.ge.npcs[p.clickId] == null || Main.m.ge.npcs[p.clickId].isDead)
        {
            p.npcOption1 = false;
            return;
        }
        p.requestFaceTo(p.clickId);
        if(Main.m.ge.getDistance(p.clickX, p.clickY, p.absX, p.absY) == 1)
        {
            p.npcOption2 = false;
            NPC n = Main.m.ge.npcs[p.clickId];
            switch(n.npcType)
            {
                default:
                    Main.m.log("[" + p.playerIndex + "-" + p.username + "] NPC option 1 " + n.npcType);
                break;
            }
        }
    }
}